'use strict';
const jsonCommon = require('yi-json-common');
const handler = (req, res, next) => {
    req.mongo.collection('menu').find({}).toArray((e,r)=> {
        if (e) return res.err.mongoError();
        let tree = jsonCommon.BuildTree(r);
        tree = jsonCommon.SortArray(tree,"ord",1);
        jsonCommon.SetPath(tree);
        res.reply({code:0,message:"查询成功",data:tree});
    });
};

module.exports = {
    open:true,
    description:'获取菜单树形结构',
    handler: handler
};